package by.gravity.common.task;

import android.os.Build;

public abstract class AsyncTask<Params, Progress, Result> extends android.os.AsyncTask<Params, Progress, Result> {

	private OnLoadCompleteListener<Result> listener;

	public AsyncTask() {

	}

	public AsyncTask(OnLoadCompleteListener<Result> loadCompleteListener) {
		this.listener = loadCompleteListener;
	}

	public void start(Params... params) {
		if (Build.VERSION.SDK_INT < 11) {
			execute(params);
		} else {
			executeOnExecutor(THREAD_POOL_EXECUTOR, params);
		}
	}

	@Override
	protected void onPostExecute(Result result) {
		super.onPostExecute(result);
		if (listener != null) {
			listener.onComplete(result);
		}
	}

}
